home *** CD-ROM | disk | FTP | other *** search
- ;FILE :XQPRINT
- ;USEAGE :call xqprint(a$,x%,y%,attr%,page%)
-
- xqprint segment
- assume cs:xqprint
- push bp ;Nothing new
- mov bp,sp ;now we can get parameters
- push ds ;save it too!
-
- ;First let's get our dataseg to the string's data
- les di,[bp+016h] ;Get string descripters seg/address
- mov dx,ds:[0]
- push dx
- pop ds
- mov cx,es:[di] ;Length of string
- and cx,0efffh ;Mask off upper bit, it's reserved.
- jz xqpend ;Null string? Just exit then
- mov si,es:[di+2] ;Offset of string
-
- les di,[bp+0ah] ;Let's get attr and push it
- mov ax,es:[di]
- push ax ;Push color/attribute
-
- les di,[bp+06h] ;Now let's get output page.
- mov ax,es:[di]
- push ax ;Okay, put in on stack too.
-
- les di,[bp+0eh] ;X pos
- mov ax,es:[di] ;okay, got x pos now
- push ax ;save x pos on stack
-
- les di,[bp+12h] ;Y pos address
- mov ax,es:[di] ;ax now has ypos
- dec ax ;ypos-1
-
- mov bx,040h ;Let's find screen width
- mov es,bx ;Be nice, don't assume 80 chars.
- mul word ptr es:[004ah] ;this holds display width in chars
- pop di ;xposition
- dec di
- add di,ax
- shl di,1 ;multiply offset by 2 (2 bytes/char)
- mov dx,es:[0063h] ;Let's find out where status port is
- add dx,6 ;okay.. we want 3d6
-
- mov ax,0b000h ;Monochrome, now are we color?
- cld ;Clear direction flag.
-
- mov bx,es:[010h] ;Let's see
- and bx,030h ;now should hold a 20
- cmp bx,030h ;Are we color?
- jz monocm ;Nope, we'v got address. it's monochrome
-
- mov ah,0b8h ;We're color! so set hi addr.
- pop bx ;Page to write on.
- or bx,bx ;0?
- jz page0 ;jump if we iz.
- pagelop:add di,1000h ;go forward a page
- dec bx
- jnz pagelop ;branch if we have more pages to go
- page0: mov es,ax ;set ES to display page
- pop bx ;Color they want/Attribute
- mov bh,bl ;Put color up high
-
- ;This is main output loop
- mainout:lodsb ;get a char into accumulator from SI
- mov bl,al ;put char in bl
- cli ;turn off irqs while we wait for horz go.
-
- notyet: in al,dx ;from video board (this avoids snow)
- shr al,1
- jb notyet
-
- notyet2:in al,dx ;Okay, now let's make sure it's ready
- shr al,1
- jnb notyet2
-
- mov ax,bx ;char,attribute
- stosw ;Okay write out char
- sti ;Re-enable irq
- loop mainout
- jmp xqpend ;goto end
-
- monocm: mov es,ax
- pop bx ;Page is pushed on stack, we don't use it.
- pop ax
- mov ah,al ;Move color to hi part of byte
- monoout:lodsb ;get char in al
- stosw ;out al+ah
- loop monoout
-
- xqpend: pop ds
- pop bp
- xqprint ends
- end
-